/*
 * @Description: 
 * @Author: Johnson
 * @Date: 2021-11-26 15:36:06
 * @LastEditor: Johnson
 * @LastEditTime: 2022-02-17 17:00:06
 */
/*
  将下面异步代码使用 Promise 的方法改进
  尽量用看上去像同步代码的方式
  setTimeout(function () {
    var a = 'hello'
    setTimeout(function () {
      var b = 'lagou'
      setTimeout(function () {
        var c = 'I ♥ U'
        console.log(a + b +c)
      }, 10)
    }, 10)
  }, 10)
*/

Promise.resolve('hello').then(v => v + 'lagou').then(v => console.log(v + 'I ♥ U'))

const p1 = new Promise((reslove) => {
  setTimeout(() => {
    reslove('hello')
  }, 10);
})
const p2 = new Promise((reslove) => {
  setTimeout(() => {
    reslove('lagou')
  }, 10);
})
const p3 = new Promise((reslove) => {
  setTimeout(() => {
    reslove('I ♥ U')
  }, 10);
})

p1.then(a => p2.then(b => p3.then(c => console.log(a + b + c))))
